 insert
    overwrite
    table jms_dm.dm_mng_customer_daliy_project_summary_dt
    partition
    (dt)
select project_name                                                                    --项目名称
     , date_time                                                                       --日期
     , sum(waybill_total)                                  as waybill_total            --总订单量
     , sum(cancel_num)                                     as cancel_num               --总取消量
     , sum(need_taking_num)                                as need_taking_num          --应揽收量
     , sum(actual_taking_num)                              as actual_taking_num        --实际揽收量
     , sum(no_taking_num)                                  as no_taking_num            --有单未揽收量
     , sum(lack_taking_num)                                as lack_taking_num          --有单漏揽收量
     , sum(transport_num)                                  as transport_num            --运输中量
     , sum(del_war_num)                                    as del_war_num              --派件中量
     , sum(no_safe_num)                                    as no_safe_num              --未妥投量
     , sum(sign_num)                                       as sign_num                 --已签收量
     , sum(intercept_num)                                  as intercept_num            --拦截量
     , sum(success_intercept_num)                          as success_intercept_num    --成功拦截量
     , sum(7d_update_intercept_num)                        as 7d_update_intercept_num  --轨迹断更量
     , sum(work_order_num)                                 as work_order_num           --客诉量
     , sum(arbitration_num)                                as arbitration_num          --丢失量
     , sum(express_num)                                    as express_num              --破损量
     , sum(xj_sign)                                        as xj_sign                  --虚假签收量
     , sum(sign_in_num)                                    as sign_in_num              --时效内签收量
     , sum(sign_out_num)                                   as sign_out_num             --超时效签收量
     , sum(nosign_in_num)                                  as nosign_in_num            --时效内未签收量
     , sum(nosign_out_num)                                 as nosign_out_num           --超时效内未签收量
     , round(sum(sign_in_num) / sum(actual_taking_num), 6) as sign_rate                --时效达成率
     , sum(on_taking_sum)                                  as on_taking_sum            --准点揽收量
     , sum(have_taking_no_send_num)                        as have_taking_no_send_num  --有揽未发量
     , sum(have_send_no_arrival_num)                       as have_send_no_arrival_num --有发未到量
     , customer_agent_code
     , customer_agent_name
     , sum(actual_taking_num_6hour)                        as actual_taking_num_6hour
     , customer_network_code                                                           --客户所属网点
     , customer_network_name                                                           --客户所属网点
     , date_time                                           as dt
from jms_dm.dm_mng_customer_daliy_customer_summary_dt
where dt >= date_add('{{ execution_date | cst_ds }}', -44)
  and dt <= '{{ execution_date | cst_ds }}'
  and project_name is not null
group by project_name          --项目名称
       , date_time             --日期
       , customer_agent_code
       , customer_agent_name
       , customer_network_code --客户所属网点
       , customer_network_name --客户所属网点
    distribute by dt
;
